unit uTip;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TFrmTip = class(TForm)
    Timer1: TTimer;
    timerShow: TTimer;
    timerHide: TTimer;
    Panel1: TPanel;
    lblMsg: TLabel;
    procedure Timer1Timer(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure timerShowTimer(Sender: TObject);
    procedure timerHideTimer(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
    tipmsg: string;
  public
    { Public declarations }
    class function ShowTip(msg: string): Boolean;
  end;

var
  FrmTip: TFrmTip;

implementation

{$R *.dfm}

{ TFrmTip }

class function TFrmTip.ShowTip(msg: string): Boolean;
begin
  with TFrmTip.Create(nil) do
  begin
    tipmsg := msg;
    Show;
  end;
end;

procedure TFrmTip.Timer1Timer(Sender: TObject);
begin
  Timer1.Enabled := False;
  timerHide.Enabled := True;
end;

procedure TFrmTip.FormShow(Sender: TObject);
begin
  lblMsg.Caption := tipmsg;
  timerShow.Enabled := True;
//  Timer1.Enabled := True;
end;

procedure TFrmTip.timerShowTimer(Sender: TObject);
var
  i: Integer;
begin
  timerShow.Enabled := False;
  Self.Left := Screen.WorkAreaWidth - Self.Width;
  if (Self.Top<Screen.WorkAreaHeight-Self.Height) then
  begin
    Self.Top := Screen.WorkAreaHeight;
  end
  else if (Self.Top<=Screen.WorkAreaHeight)and(Self.Top>Screen.WorkAreaHeight-Self.Height) then
  begin
    Self.Top := Self.Top - 1;
  end
  else
  begin
    Exit;
  end;
  Application.ProcessMessages;
  timerShow.Enabled := True;
end;

procedure TFrmTip.timerHideTimer(Sender: TObject);
var
  i: Integer;
begin
  timerHide.Enabled := False;
  Self.Left := Screen.WorkAreaWidth - Self.Width;
  if (Self.Top>Screen.WorkAreaHeight) then
  begin
    Self.Top := Screen.WorkAreaHeight-Self.Height;
  end
  else if (Self.Top<Screen.WorkAreaHeight)and(Self.Top>=Screen.WorkAreaHeight-Self.Height) then
  begin
    Self.Top := Self.Top + 1;
  end
  else
  begin
    Self.Close;
    Exit;
  end;
  Application.ProcessMessages;
  timerHide.Enabled := True;
end;

procedure TFrmTip.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Self.Free;
end;

end.
